package com.vincent.sciinfo.config;

import com.vincent.sciinfo.interceptor.JWTInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorWebConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // addPathPatterns拦截所有请求 excludePathPatterns排除特殊的请求
        registry.addInterceptor(new JWTInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/user/login")
                .excludePathPatterns("/loginCount/checkUserCountNum")
                .excludePathPatterns("/teacher/getTeacherInfor");
    }

//    @Bean
//    public JWTInterceptor JWTInterceptor() {
//        return new JWTInterceptor();
//    }


}
